import java.lang.reflect.*;

class FruitDynamicProxy {
    private Object target;

    public FruitDynamicProxy(Object target) {
        this.target = target;
    }

    public Object getProxyInstance() {
        return Proxy.newProxyInstance(
                target.getClass().getClassLoader(),
                target.getClass().getInterfaces(),
                new InvocationHandler() {
                    @Override
                    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                        preProcess();
                        Object result = method.invoke(target, args);
                        postProcess();
                        return result;
                    }
                }
        );
    }

    private void preProcess() {
        System.out.println("[动态代理] 预处理：消毒处理");
    }

    private void postProcess() {
        System.out.println("[动态代理] 后处理：清理残渣\n");
    }
}